#include <bits/stdc++.h>
using namespace std;

#define ll long long
const int N = 1e6;
int arr[N];
int n;
ll k;
unordered_map<ll, int> mp;
class Solution 
{
public:
    int subarraySum(vector<int>& nums)
    {
        int n = nums.size();
        vector<int> arr;
        arr.resize(n + 1, 0);
  
        partial_sum(nums.begin(), nums.end(), arr.begin() + 1);

        int ans = 0;
        for (int i = 0; i < n; i++)
        { 
            int start = max(0, i - nums[i]);
            ans += arr[i + 1] - arr[start];
        }
        return ans;
    }
};

ll sum;
int main()
{
    scanf("%d %lld", &n, &k);
    int ans = 0;
    mp.insert({0, 0});
    for (int i = 1; i <= n; i++)
    {
        ll k;
        scanf("%lld", &k);
        sum += k;
        if (mp.find(sum) == mp.end())
            mp.insert({sum, i});

        if (mp.find(sum - k) != mp.end())
        {
            ans = max(ans, i - mp[sum]);
        }
    }
    printf("%d\n", ans);

    return 0;
}